package com.mine.springmvc.thread;

//测试守护线程
public class TestDaemon {

    public static void main(String[] args) {
        God god = new God();
        You you = new You();

        Thread thread = new Thread(god); // 守护线程
        thread.setDaemon(true); // 默认false都是用户线程,true：守护线程
        thread.start();


        new Thread(you).start(); // 你启动了 用户线程
    }
}


//上帝
class God implements Runnable{

    @Override
    public void run() {
        while (true){
            System.out.println("========GOD BLESS YOU============");
        }
    }
}



//你

class You implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i < 36500; i++) {
            System.out.println("开心第："+i +"天");
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("========goodbye world!!============");
    }
}
